package com.carl.zlds.controller.web;

import com.carl.zlds.tool.common.result.Result;
import com.carl.zlds.annotation.Login;
import com.carl.zlds.pojo.dto.AdSearchDTO;
import com.carl.zlds.pojo.vo.AdVO;
import com.carl.zlds.service.IAdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author carl
 */
@Slf4j
@RestController(value = "web.adController")
@RequestMapping("/web/ad")
@Api(tags = {"客户端 - 广告管理"})
public class AdController {
    private final IAdService adService;

    @Autowired
    public AdController(IAdService adService) {
        this.adService = adService;
    }

    @ApiOperation("广告列表")
    @GetMapping(value = "/list")
    @Login(needToken = false)
    public Result<Map<String, Object>> list(AdSearchDTO dto) {
        List<AdVO> list = adService.getAdListByWeb(dto);
        Map<String, Object> map = new HashMap<>(1);
        map.put("list", list);
        return Result.success(map);
    }
}
